﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Utils.DC.Web.UI;
using Entity;

public partial class admin_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["login"] != null)
        {
            Response.Redirect("../Admin/Pages/Index.aspx");
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {     
        Admin admin = new AdminUI().Login(txtUser.Text.Trim(), Security.Encrypt(txtPass.Text.Trim()));

        if (admin != null)
        {
            lblError.Visible = false;
            Session.Timeout = 30;
            Session["login"] = admin;
            Response.Redirect("../Admin/Pages/Index.aspx");

        }
        else
        {
            lblError.Visible = true;
        }

    }
}
